package increment;

import java.util.Random;
import java.util.Scanner;
public class Core_Func {
        public  String problemAnswer(){
            Random r = new Random();
            int answer;
            int choice;
            int a;
            int b;
            do {
                choice = r.nextInt(2);
                choice =  choice == 1?1:-1;
                a=r.nextInt(100);
                b=r.nextInt(100);
                answer = a + choice * b;
            }while (answer  < 0 || answer > 100);
            String symbol = choice == 1?"+":"-";
            return new Integer(a).toString() +" " + symbol + " " +  new Integer(b).toString();
        }
        public static int getAnswer(String p){
            int answer  = Integer.parseInt(p.split(" ")[0]) +
                    (44 - p.split(" ")[1].charAt(0))*
                            Integer.parseInt(p.split(" ")[2]);
            return answer;
        }
        public static void main(String[] args) {
            int count_all=0,count_right=0;
            while(true){
                Core_Func c = new Core_Func();
                String p = c.problemAnswer();
                System.out.println(p);
                int answer  = getAnswer(p);
                Scanner scanner = new Scanner(System.in);
                String myAnswer=scanner.nextLine();
                if("N".equals(myAnswer)) break;
                count_all++;
                if(answer == Integer.parseInt(myAnswer)){
                    count_right++;
                    System.out.println("对了");
                }else{
                    System.out.println("错了");
                    System.out.println("正确答案是" + answer);
                }
            }
            System.out.println("你总共做了"+count_all+"道题");
            System.out.println("对了"+count_right+"道题");
            System.out.println("正确率为"+(float)count_right/count_all*100+"%");
        }

}
